package com.AJava1710D.设计模式.单例.枚举单例2;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2020/10/6  8:24
 * 描述: 普通单例模式(懒汉式)  面试问题：说说双重检查加锁单例模式为什么两次if判断？
 */
public class PuTongDanLi2 {

    private PuTongDanLi2(){}

    private static PuTongDanLi2 puTongDanLi2;


    public static PuTongDanLi2 getInstance(){

      if(puTongDanLi2==null){
          synchronized (PuTongDanLi2.class){
              if(puTongDanLi2==null){
                  puTongDanLi2=new PuTongDanLi2();
              }
          }
      }
        return puTongDanLi2;
    }

}
